import { http } from "@/utils/http";

export type PageParams = {
  pageNum: number;
  pageSize: number;
}

/**
 * 统一响应格式
 */
export type CommonResponse<T = any> = {
  code: number;
  message: string;
  data: T;
}

/**
 * 上传图片接口
 */
export function uploadImage(file: File): Promise<string> {
  return new Promise<string>((resolve, reject) => {
    const formData = new FormData();
    formData.append('file', file);
    http.request('post', '/api/platform/file/upload/image', {
      data: formData
    }).then((res: CommonResponse) => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}